package com.qf.service;

import com.qf.dao.UserDao;
import com.qf.dao.UserDaoImpl;
import com.qf.pojo.User;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.util.List;

public class UserServiceImpl implements UserService {

    private UserDao userDao;

    public UserServiceImpl() {
    }

    public UserServiceImpl(UserDao userDao) {
        this.userDao = userDao;
    }

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    public User findUserById(Integer id) {
        User userById = userDao.findUserById(11);
        return userById;
    }


    @PostConstruct
    public void init() {
        System.out.println("===  init  初始化方法执行");
    }

    public User getUserById(Integer id) throws Exception {
//        BeanFactory beanFactory=new BeanFactory("/bean.properties");
//       BeanFactory beanFactory=new BeanFactory("/bean.properties");
//        UserDao userDao1 =(UserDao) beanFactory.getBean("userDao");
//        User user = userDao1.findUserById(1111);
        System.out.println(" ===构建完成执行业务==");
        User userById = userDao.findUserById(111);
        return userById;
    }

    public List<User> findAll() {
        System.out.println("执行了 UserServiceImpl 类的finaAll方法");
        return null;
    }

    public void insertUser(User user) {
        System.out.println("执行了 UserServiceImpl 类的insertUser方法");
    }

    public void updateUser(User user) {
        System.out.println("执行了 UserServiceImpl 类的updateUser方法");
    }

    public void deleteById(Integer id) {
        System.out.println("执行了 UserServiceImpl 类的deleteById方法");
    }


    @PreDestroy
    public void destroy() {
        System.out.println("===destroy  销毁方法");
    }


}
